//================= MISSING INFORMATION =======================================//
//
// Purpose: HUD Icon to show what secondary firing mode is selected
//
//=============================================================================//

#include "cbase.h"
#include "hud.h"
#include "hud_macros.h"
#include "view.h"

#include "iclientmode.h"

#include "KeyValues.h"
#include "vgui_controls/AnimationController.h"
#include "vgui/ILocalize.h"
#include "vgui/ISurface.h"
#include "hudelement.h"

#include "c_basehlplayer.h"

using namespace vgui;

// memdbgon must be the last include file in a .cpp file!!!
#include "tier0/memdbgon.h"

//-----------------------------------------------------------------------------
// Purpose: HUD Secondary Mode Icon
//-----------------------------------------------------------------------------
class CHudSecondaryIcon : public CHudElement, public vgui::Panel
{
	DECLARE_CLASS_SIMPLE( CHudSecondaryIcon, vgui::Panel );

public:
	CHudSecondaryIcon( const char *pElementName );
	void VidInit( void );
	void Reset( void );
	virtual bool ShouldDraw( void );

private:
	virtual void Paint();
//	virtual void ApplySchemeSettings( vgui::IScheme *scheme );

private:
	
	bool    m_bIsVisible;
	CPanelAnimationVar( vgui::HFont, m_hIconFont, "IconFont", "HudNumbers" );

	CPanelAnimationVarAliasType( float, icon_xpos, "icon_xpos", "0", "proportional_float" );
	CPanelAnimationVarAliasType( float, icon_ypos, "icon_ypos", "0", "proportional_float" );
};

DECLARE_HUDELEMENT( CHudSecondaryIcon );

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CHudSecondaryIcon::CHudSecondaryIcon( const char *pElementName ) : CHudElement( pElementName ), BaseClass(NULL, "HudSecondaryModeIcon")
{
	vgui::Panel *pParent = g_pClientMode->GetViewport();
	SetParent( pParent );
	
	SetHiddenBits( HIDEHUD_HEALTH | HIDEHUD_PLAYERDEAD | HIDEHUD_NEEDSUIT );
}

//-----------------------------------------------------------------------------
// Purpose: 
/*-----------------------------------------------------------------------------
void CHudSecondaryIcon::ApplySchemeSettings( IScheme *scheme )
{
	BaseClass::ApplySchemeSettings( scheme );
	SetPaintBackgroundEnabled( false );
}*/

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudSecondaryIcon::VidInit( void )
{
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CHudSecondaryIcon::Reset( void )
{
	SetVisible( false );
	m_bIsVisible = false;
}

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CHudSecondaryIcon::ShouldDraw( void )
{
	C_BaseHLPlayer *pPlayer = (C_BaseHLPlayer *)ToBasePlayer( C_BasePlayer::GetLocalPlayer() );

	if ( !pPlayer )
		return false;

	if ( pPlayer->IsInAVehicle() )
		return false;

	C_BaseCombatWeapon *pActiveWeapon = pPlayer->GetActiveWeapon();

	if ( !pActiveWeapon )
		return false;

	if ( V_stricmp( pActiveWeapon->GetClassname(), "weapon_ar2" ) )
		return false;

	if ( !CHudElement::ShouldDraw() )
		return false;

	return true;
}

//-----------------------------------------------------------------------------
// Purpose: Paint Function Overwrite for this panel.
//-----------------------------------------------------------------------------
void CHudSecondaryIcon::Paint()
{
	BaseClass::Paint();

	C_BaseHLPlayer *pPlayer = (C_BaseHLPlayer *)ToBasePlayer( C_BasePlayer::GetLocalPlayer() );

	if ( !pPlayer )
		return;

	surface()->DrawSetTextColor( GetFgColor() );
	surface()->DrawSetTextFont( m_hIconFont );
	surface()->DrawSetTextPos( icon_xpos, icon_ypos );

	if ( pPlayer->OICW_GetMode() )
		surface()->DrawUnicodeChar('t');
	else
		surface()->DrawUnicodeChar('E');
}